# 可以为不同的数据类型（混装）
name_list = ["a", "b", True, 666, 53.3]
print(name_list)
print(type(name_list))
for x in name_list:
    print(x, end='')
    print(type(x))

# 空容器
name_list = []
name_lsit = list()
# 下标索引
name_list = [[1, 2, 3], 1, 2, 3]
print(name_list[0])
print(name_list[0][2])
print(name_list[1])
print(name_list[2])
print(name_list[-1])


# 常用方法
print("常用方法")
#根据元素查找下标
print(name_list.index(3))
#修改值
name_list[1] = 10
print(name_list[1])
print(name_list)
#插入
name_list.insert(1,"zzz")
print(name_list)
#单个追加
name_list.append(4)
print(name_list)
#批量追加
name_list.extend([5,6,7])
print(name_list)
#删除del pop(有结果)
del name_list[-1]
print(name_list)
a=name_list.pop(0)
print(a)
print(name_list)
#remove 移除第一个出现的元素
name_list.append(1)
name_list.append(1)
print(name_list)
name_list.remove(1)
print(name_list)
#clear
#name_list.clear()
#统计元素个数 count
print(name_list.count(1))
print(len(name_list))

#遍历元素
def while_func(data):
    index=0
    while index<len(data):
        print(data[index]," ",end="")
        index+=1
    print()
def for_func(data):
    for x in data:
        print(x," ",end="")
    print()


print("while 循环")
while_func(name_list)

print("for 循环")
for_func(name_list)


#序列
name_list=[1,2,3,4,5,6,7,8,9,10]
print("序列")
print(name_list[:])
print(name_list[::2])
print(name_list[::-1])
print(name_list[0:4])
print(name_list[4:0:-1])
